<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
require_once("lib/my_library.php");
//Includes
use_unit("components4phpfull/jtdivwindow.inc.php");
use_unit("components4phpfull/jtgroupbox.inc.php");
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("comctrls.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class Veh_Fuel_Edit extends Page
{
   public $lblNo = null;
   public $edNo = null;
   public $Label3 = null;
   public $cmbmode = null;
   public $JSRoundDecimal = null;
   public $Label1 = null;
   public $Label2 = null;
   public $lblOdometerNow = null;
   public $lblOdNow = null;
   public $lblPrice = null;
   public $lblGallons = null;
   public $Label12 = null;
   public $hfError = null;
   public $JSValidate = null;
   public $JTDivFuel = null;
   public $JTGroupBox2 = null;
   public $btnAddFuel = null;
   public $btnDelFuel = null;
   public $edFuel = null;
   public $listFuel = null;
   public $JTDivAccount = null;
   public $JTGroupBox1 = null;
   public $btnAddAccount = null;
   public $btnDelAccount = null;
   public $edAccount = null;
   public $listAccount = null;
   public $JTDivType = null;
   public $JTGroupBox5 = null;
   public $btnAddType = null;
   public $btnDelType = null;
   public $edType = null;
   public $listType = null;
   public $JTDivCity = null;
   public $JTGroupBox4 = null;
   public $btnAddCity = null;
   public $btnDelCity = null;
   public $edCity = null;
   public $listCity = null;
   public $JTDivDealer = null;
   public $JTGroupBox3 = null;
   public $btnaddDealer = null;
   public $btnDelDealer = null;
   public $edDealer = null;
   public $listDealer = null;
   public $btnShowDealer = null;
   public $lblDealer = null;
   public $cmbDealer = null;
   public $dpdate = null;
   public $btnShowType = null;
   public $btnShowFuel = null;
   public $btnShowAccount = null;
   public $edPrice = null;
   public $edEngine = null;
   public $lblEngine = null;
   public $lblComments = null;
   public $memoComments = null;
   public $lblType = null;
   public $cmbType = null;
   public $lblBrand = null;
   public $cmbBrand = null;
   public $lblDriver = null;
   public $cmbDriver = null;
   public $lblAccount = null;
   public $cmbAccount = null;
   public $edTotCost = null;
   public $lblTotal = null;
   public $edGallons = null;
   public $edMiles = null;
   public $lblMiles = null;
   public $edOdNow = null;
   public $lblLastOdometer = null;
   public $edOdLast = null;
   public $lblDate = null;
   public $btnShowCity = null;
   public $lblCity = null;
   public $cmbCity = null;
   public $JTJavaScript9 = null;
   public $JTJavaScript8 = null;
   public $JTJavaScript7 = null;
   public $JTJavaScript6 = null;
   public $JTJavaScript5 = null;
   public $JTJavaScript4 = null;
   public $JTJavaScript3 = null;
   public $JTJavaScript2 = null;
   public $JTJavaScript1 = null;
   public $JTJavaScript15 = null;
   public $JTJavaScript14 = null;
   public $JTJavaScript13 = null;
   public $JTJavaScript12 = null;
   public $JTJavaScript11 = null;
   public $JTJavaScript10 = null;
   public $btnCancel = null;
   public $btnSubmit = null;
   public $compid = null;
   public $JTSiteTheme1 = null;
   public $imgBack = null;
   public $Image3 = null;
   public $hiddenFuel = null;
   public $hiddenVeh = null;
   function cmbmodeJSChange($sender, $params)
   {

   ?>
   var mode = document.getElementById('cmbmode').value;
       //alert(mode);
       if(mode=='Select' || mode=='Cash')
       {
       document.getElementById('lblNo_outer').style.visibility='hidden';
       document.getElementById('edNo_outer').style.visibility='hidden';
       }
       if(mode=='FleetCard' || mode=='Credit')
       {
       document.getElementById('lblNo_outer').style.visibility='visible';
       document.getElementById('edNo_outer').style.visibility='visible';
       }

   <?php

   }

   function Veh_Fuel_EditJSLoad($sender, $params)
   {

   ?>
   var mode = document.getElementById('cmbmode').value;
       //alert(mode);
       if(mode=='Select' || mode=='Cash')
       {
       document.getElementById('lblNo_outer').style.visibility='hidden';
       document.getElementById('edNo_outer').style.visibility='hidden';
       }
       if(mode=='FleetCard' || mode=='Credit')
       {
       document.getElementById('lblNo_outer').style.visibility='visible';
       document.getElementById('edNo_outer').style.visibility='visible';
       }

   <?php

   }

   function edPriceJSBlur($sender, $params)
   {

   ?>
   //Add your javascript code here
   validateRequire('edPrice','lblPrice');
   <?php

   }

   function edGallonsJSBlur($sender, $params)
   {

   ?>
   //Add your javascript code here
   validateRequire('edGallons','lblGallons');
   <?php

   }

   function edOdNowJSBlur($sender, $params)
   {

   ?>
   //Add your javascript code here
   validateRequire('edOdNow','lblOdNow');
   <?php

   }

   function cmbTypeJSChange($sender, $params)
   {
   echo $this->cmbType->ajaxCall('price');
    ?>
    return false;
    <?php
   }

   function cmbBrandJSChange($sender, $params)
   {
    echo $this->cmbBrand->ajaxCall('price');
    ?>
    return false;
    <?php

   }


   function btnDelTypeJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var TypeIndex = document.getElementById('listType').selectedIndex;
       var TypeValue = document.getElementById('listType')[TypeIndex].value;
       var comp = document.getElementById('compid').value;
       AjaxType3(TypeValue,comp);
       <?php

       }

       function btnAddTypeJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var addtype = document.getElementById('edType').value;
       var compider = document.getElementById('compid').value;
       AjaxType2(addtype,compider);
       document.Veh_Fuel_Edit.edType.value = "";
       <?php

       }

       function btnShowTypeJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivType').Show();
       document.Veh_Fuel_Edit.edType.value = "";
       <?php

       }

       function btnShowCityJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivCity').Show();
       document.Veh_Fuel_Edit.edCity.value = "";
       <?php

       }

       function btnAddCityJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var addcity = document.getElementById('edCity').value;
       var compider = document.getElementById('compid').value;
       AjaxCity2(addcity,compider);
       document.Veh_Fuel_Edit.edCity.value = "";
       <?php

       }

       function btnDelCityJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var CityIndex = document.getElementById('listCity').selectedIndex;
       var CityValue = document.getElementById('listCity')[CityIndex].value;
       var comp = document.getElementById('compid').value;
       AjaxCity3(CityValue,comp);
       <?php

       }


       function btnShowDealerJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivDealer').Show();
       document.Veh_Fuel_Edit.edDealer.value = "";
       <?php

       }

       function btnDelDealerJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var DealerIndex = document.getElementById('listDealer').selectedIndex;
       var DealerValue = document.getElementById('listDealer')[DealerIndex].value;
       var comp = document.getElementById('compid').value;
       AjaxDealer3(DealerValue,comp);
       <?php

       }

       function btnaddDealerJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var adddealer = document.getElementById('edDealer').value;
       var compider = document.getElementById('compid').value;
       AjaxDealer2(adddealer,compider);
       document.Veh_Fuel_Edit.edDealer.value = "";
       <?php

       }

       function btnAddFuelJSClick($sender, $params)
        {

       ?>
       //Add your javascript code here
       var addfuel = document.getElementById('edFuel').value;
       var compider = document.getElementById('compid').value;
       AjaxFuel2(addfuel,compider);
       document.Veh_Fuel_Edit.edFuel.value = "";
       <?php

       }

      function btnDelFuelJSClick($sender, $params)
      {

      ?>
       //Add your javascript code here
     var FuelIndex = document.getElementById('listFuel').selectedIndex;
     var FuelValue = document.getElementById('listFuel')[FuelIndex].value;
     var comp = document.getElementById('compid').value;
     AjaxFuel3(FuelValue,comp);
     <?php

      }

      function btnShowFuelJSClick($sender, $params)
      {

      ?>
      //Add your javascript code here
      document.getElementById('JTDivFuel').Show();
      document.Veh_Fuel_Edit.edFuel.value = "";
      <?php

      }


      function btnDelAccountJSClick($sender, $params)
      {

      ?>
      //Add your javascript code here
      var dropdownIndex = document.getElementById('listAccount').selectedIndex;
      var dropdownValue = document.getElementById('listAccount')[dropdownIndex].value;
      var com = document.getElementById('compid').value;
      AjaxAccount3(dropdownValue,com);
      <?php

       }

      function btnAddAccountJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var addaccount = document.getElementById('edAccount').value;
       var compider = document.getElementById('compid').value;
       AjaxAccount2(addaccount,compider);
       document.Veh_Fuel_Edit.edAccount.value = "";
       <?php

       }

       function btnShowAccountJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivAccount').Show();
        document.Veh_Fuel_Edit.edAccount.value = "";
       <?php

       }

     function edPriceJSKeyUp($sender, $params)
     {

     ?>
     //Add your javascript code here
     document.Veh_Fuel_Edit.edTotCost.value = roundNumber((document.Veh_Fuel_Edit.edGallons.value) * (document.Veh_Fuel_Edit.edPrice.value),2);

     //accept only numbers
      var numero = document.getElementById("edPrice").value;
      var first = numero.indexOf('.');
      var last = numero.lastIndexOf('.');

       while(isNaN(numero))
       {
        haba = numero.length;
        haba = haba - 1;
        numero = numero.substr(0,haba);
       }

       while(first!=last)
       {
        numero = numero.slice(0,last);
        first = numero.indexOf('.');
        last = numero.lastIndexOf('.');
       }
       document.getElementById("edPrice").value = numero;

     <?php

     }

   function edGallonsJSKeyUp($sender, $params)
   {

    ?>
       //Add your javascript code here
       document.Veh_Fuel_Edit.edTotCost.value = roundNumber((document.Veh_Fuel_Edit.edGallons.value) * (document.Veh_Fuel_Edit.edPrice.value),2);
       <?php

   }

   function imgBackJSMouseOut($sender, $params)
   {

?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back.png"
       <?php

   }

   function imgBackJSMouseOver($sender, $params)
   {

    ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back2.png"
       <?php

   }

   function btnSubmitClick($sender, $params)
   {
      $my_library = new my_library();

      $vehicle_id = $this->hiddenVeh->getValue();

      //$my_library->updateCurrentTrackingValue($vehicle_id, $this->edOdNow->Text);

      $driver_id = $this->cmbDriver->getItemIndex();
      $result_drive = mysql_query("select * from employee_tbl where company_id='".$_SESSION['company_id']."' and autoid='".$driver_id."'");
      $row_drive = mysql_fetch_array($result_drive);

      $fuel_t = $this->cmbType->getItemIndex();
      $result_ftype = mysql_query("select value from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND id='".$fuel_t."'");
      $row_ftype = mysql_fetch_array($result_ftype);
      $ftype2 = $row_ftype['value'];

      $query1 = "select * from veh_fuel_tbl where vehicle_id='" . $this->hiddenVeh->getValue() . "'and fuel_id='" . $this->hiddenFuel->getValue() . "'";
      $result = mysql_query($query1)or die(mysql_error());
      $row = mysql_fetch_array($result);

       //$this->validateRequired($this->edOdNow->Text, 'lblOdNow');
       $this->validateRequired($this->edGallons->Text, 'lblGallons');
       $this->validateRequired($this->edPrice->Text, 'lblPrice');
       $error = $this->hfError->getValue();
       if($error == '1' || $number != $key)
       {
          $this->hfError->setValue('0');
          return false;
       }
       else if($error == '0')
       {
      $query_update = "update veh_fuel_tbl set
       date = '" . $this->dpdate->Text . "',
       payment_mode = '".$this->cmbmode->getItemIndex()."',
       card_num = '".$this->edNo->Text."',
       last_odometer = '" . $this->edOdLast->Text . "',
       present_odometer = '" . $this->edOdNow->Text . "',
       miles = '" . $this->edMiles->Text . "',
       gallons = '" . $this->edGallons->Text . "',
       price = '" . $this->edPrice->Text . "',
       tot_cost = '" . $this->edTotCost->Text . "',
       engine = '" . $this->edEngine->Text . "',
       brand = '" . $this->cmbBrand->getItemIndex() . "',
       dealer = '" . $this->cmbDealer->getItemIndex() . "',
       account = '" . $this->cmbAccount->getItemIndex() . "',
       province = '" . $this->cmbCity->getItemIndex() . "',
       driver = '" . $row_drive['lname'].','.$row_drive['fname'] . "',
       driver_id = '".$driver_id."',
       type = '" . $ftype2 . "',
       ftype_id = '".$this->cmbType->getItemIndex()."',
       comments = '" . $this->memoComments->Text . "'
       where vehicle_id='" . $this->hiddenVeh->getValue() . "' and fuel_id='" . $this->hiddenFuel->getValue() . "'";
      mysql_query($query_update)or die(mysql_error());


      mysql_query("update rou_fuel_tbl set
       fuel_date = '".$this->dpdate->getText()."',
       last_odometer = '".$this->edOdLast->Text."',
       present_odometer = '".$this->edOdNow->Text."',
       miles = '".$this->edMiles->Text."',
       gallons = '".$this->edGallons->Text."',
       price = '".$this->edPrice->Text."',
       brand = '".$this->cmbBrand->getItemIndex()."',
       type = '".$this->cmbType->getItemIndex()."',
       tot_cost = '".$this->edTotCost->Text."',
       engine = '".$this->edEngine->Text."',
       dealer = '".$this->cmbDealer->getItemIndex()."',
       account = '".$this->cmbAccount->getItemIndex()."',
       province = '".$this->cmbCity->getItemIndex()."'
       where rfuel_id='".$row['route_fuel_id']."'")or die(mysql_error());


      //UPDATE CURRENT ODOMETER/HOUR
      $track = $row['track_by'];
      if($track=='distance')
      {
      $save_here = 'curr_tracking_value';
      }

      if($track=='hours')
      {
      $save_here = 'curr_hours';
      }

      mysql_query("UPDATE vehicle_tbl set ".$save_here." = '".$this->edOdNow->Text."' WHERE vehicle_id = '".$this->hiddenVeh->getValue()."'")or die(mysql_error());


      redirect('veh_fuel_list.php?veh=' . $vehicle_id);
      }

   }

   function edOdNowJSKeyUp($sender, $params)
   {

?>
       //Add your javascript code here
       document.Veh_Fuel_Edit.edMiles.value = (document.Veh_Fuel_Edit.edOdNow.value) - (document.Veh_Fuel_Edit.edOdLast.value);
       <?php

   }

   function edOdLastJSKeyUp($sender, $params)
   {

?>
       //Add your javascript code here
       document.Veh_Fuel_Edit.edMiles.value = (document.Veh_Fuel_Edit.edOdNow.value) - (document.Veh_Fuel_Edit.edOdLast.value);
       <?php

   }

   function btnCancelClick($sender, $params)
   {
      redirect('veh_fuel_list.php?veh=' . $this->hiddenVeh->getValue());
   }




   function btnUpdateClick($sender, $params)
   {
      $query_update = "UPDATE veh_fuel_tbl SET
       date='" . $this->dpdate->Text . "',
       last_odometer='" . $this->edOdLast->Text . "',
       present_odometer='" . $this->edOdNow->Text . "',
       miles='" . $this->edMiles->Text . "',
       gallons='" . $this->edGallons->Text . "',
       tot_cost='" . $this->edTotCost->Text . "',
       comments='" . $this->memoComments->Text . "',
       fuel_custom1='" . $this->edFuelCstm1->Text . "',
       fuel_custom2='" . $this->edFuelCstm2->Text . "',
       fuel_custom3='" . $this->edFuelCstm3->Text . "',
       fuel_custom4='" . $this->edFuelCstm4->Text . "'
       WHERE vehicle_id='" . $this->hiddenVeh->getValue() . "'and fuel_id ='" . $this->hiddenFuel->getValue() . "'";
      mysql_query($query_update)or die(mysql_error());


      redirect('fuel_frame.php?veh=' . $this->hiddenVeh->getValue());


   }


   function commafy($_)
       {
        return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,' , strrev( $_ ) ) );
       }



   function price()
       {
        $type_id = $this->cmbType->getItemIndex();
        $brand = $this->cmbBrand->getItemIndex();

        $query_type = "SELECT value FROM lookup_fuel_tbl WHERE id='".$type_id."'";
        $result_type = mysql_query($query_type) or die("SELECT FUEL TYPE ".mysql_error());
        $row_type = mysql_fetch_array($result_type);
        $type = $row_type['value'];

        $query_price = "SELECT price FROM fuel_price_tbl WHERE company_id='".$_SESSION['company_id']."' AND brand='".$brand."' AND type='".$type."'";
        $result_price = mysql_query($query_price) or die("SELECT PRICE ".mysql_error());
        $row_price = mysql_fetch_array($result_price);

        $price = $row_price['price'];
        $this->edPrice->Text = $price;

        $total = $this->edPrice->Text * $this->edGallons->Text;
        $this->edTotCost->setText($total);
       }

       function validateRequired($value, $lbl)
       {
          if($value == '' || $value == null)
          {
             $this->$lbl->Caption = '&darr; This field is required &darr;';
             $this->hfError->setValue('1');
          }
       }



   function Veh_Fuel_EditCreate($sender, $params)
   {
      $this->compid->Value = $_SESSION['company_id'];
      $veh_id = $_GET['veh'];
      $veh_fuel = $_GET['fuel'];
      $this->hiddenVeh->setValue($veh_id);
      $this->hiddenFuel->setValue($veh_fuel);
      $this->hfError->setValue('0');

      $this->lblOdNow->Caption = '';
      $this->lblGallons->Caption = '';
      $this->lblPrice->Caption = '';


      if($_SESSION['access_vehicle']==1)
       {
       $this->btnCancel->Visible=false;
       $this->btnSubmit->Visible=false;
       }

       if($_SESSION['access_vehicle']==2)
       {
       $this->btnCancel->Visible=true;
       $this->btnSubmit->Visible=true;
       }


      $query1 = "select * from veh_fuel_tbl where vehicle_id='" . $this->hiddenVeh->getValue() . "'and fuel_id='" . $this->hiddenFuel->getValue() . "'";
      $result = mysql_query($query1)or die(mysql_error());
      $row = mysql_fetch_array($result);

      $this->imgBack->setLink('veh_fuel_list.php?veh=' . $this->hiddenVeh->getValue());

      $this->cmbmode->ItemIndex = $row['payment_mode'];

      $this->cmbDriver->AddItem('--Select--');
      $this->cmbDriver->ItemIndex = $row['driver_id'];
      $result_driver = mysql_query("select * from employee_tbl where company_id='".$_SESSION['company_id']."' and veh_op='1'");

      while($row_driver = mysql_fetch_array($result_driver))
      {
         $this->cmbDriver->AddItem($row_driver['lname'] . ',' . $row_driver['fname'], null , $row_driver['autoid']);
      }


      $this->cmbType->AddItem('--Select--');
      $this->cmbType->ItemIndex = $row['ftype_id'];
      $result_fuel = mysql_query("select * from lookup_fuel_tbl where company_id='".$_SESSION['company_id']."' and category='octane/types' order by value asc");

      while($row_fuel = mysql_fetch_array($result_fuel))
      {
         $this->cmbType->AddItem($row_fuel['value'], null , $row_fuel['id']);
      }

       //list type/grade
      $this->listType->Clear();
      $result_type = mysql_query("select * from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='octane/types' order by value asc");

      while($row_type = mysql_fetch_array($result_type))
      {
        $this->listType->AddItem($row_type['value'], null, $row_type['id']);
      }

      $this->cmbCity->ItemIndex = $row['province'];
      $result_city = mysql_query("select value from lookup_fuel_tbl where company_id='".$_SESSION['company_id']."' and category='state/province'");

      while($row_city = mysql_fetch_array($result_city))
      {
         $this->cmbCity->AddItem($row_city['value'], null , $row_city['value']);
      }

      //list city
      $this->listCity->Clear();
      $result_ci = mysql_query("select value from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='state/province'");

      while($row_ci = mysql_fetch_array($result_ci))
      {
        $this->listCity->AddItem($row_ci['value'], null, $row_ci['value']);
      }

      $this->cmbAccount->AddItem('--Select--');
      $this->cmbAccount->ItemIndex = $row['account'];
      $result_account = mysql_query("select * from lookup_expense_tbl where company_id='".$_SESSION['company_id']."' and category='accounts'");

      while($row_account = mysql_fetch_array($result_account))
      {
         $this->cmbAccount->AddItem($row_account['value'], null , $row_account['id']);
      }

      //list account
      $this->listAccount->Clear();
      $result_acc = mysql_query("select * from lookup_expense_tbl where company_id = '".$_SESSION['company_id']."' AND category='accounts'");

      while($row_acc = mysql_fetch_array($result_acc))
      {
        $this->listAccount->AddItem($row_acc['value'], null, $row_acc['id']);
      }

      //$price = $row['price'];
      //$tot_cost = $row['tot_cost'];
      //$pr = $this->commafy($price);
      //$tot = $this->commafy($tot_cost);



      $this->dpdate->Text = $row['date'];
      $this->edOdLast->Text = $row['last_odometer'];
      $this->edOdNow->Text = $row['present_odometer'];
      $this->edMiles->Text = $row['miles'];
      $this->edGallons->Text = $row['gallons'];
      $this->edPrice->Text = $row['price'];
      $this->edTotCost->Text = $row['tot_cost'];
      $this->edEngine->Text = $row['engine'];
      $this->memoComments->Text = $row['comments'];
      $this->edNo->Text = $row['card_num'];

      $result_od = mysql_query("select * from vehicle_tbl where vehicle_id='" . $this->hiddenVeh->getValue() . "'");
      $row_od = mysql_fetch_array($result_od);
      $label_od = $row_od['track_by'];

      $tracking = $row['track_by'];
      if ($tracking=='distance')
      {
      $this->lblLastOdometer->Caption = 'Previous Odometer:';
      $this->lblOdometerNow->Caption = '*Current Odometer:';
      }

      if ($tracking=='hours')
      {
      $this->lblLastOdometer->Caption = 'Previous Hours:';
      $this->lblOdometerNow->Caption = '*Current Hours:';
      }

      /*$result_od2 = mysql_query("select * from company_measures_tbl where company_id='" . $_SESSION['company_id'] . "'");
      $row_od2 = mysql_fetch_array($result_od2);
      $label_od2 = $row_od2['custom_field'];
      if($label_od2 == '1')
      {
         $this->lblOdometerNow->Caption = 'Curr Meter:';
         $this->lblOdometerNow->Left = 426;
         $this->lblLastOdometer->Caption = 'Last Meter:';
         $this->lblLastOdometer->Left = 252;
         $this->lblMiles->Caption = 'Distance:';
         $this->lblMiles->Left = 596;
         $this->lblGallons->Caption = 'Vol Units:';
         $this->lblGallons->Left = 46;
         $this->lblGallons->Width = 58;
      }
      else
      {
         $this->lblOdometerNow->Left = 402;
         $this->lblLastOdometer->Left = 220;
         $this->lblMiles->Caption = 'Miles:';
         $this->lblMiles->Left = 601;
         $this->lblGallons->Caption = 'Gallons:';
         $this->lblGallons->Left = 54;
         $this->lblGallons->Width = 46;
      }*/

      $this->cmbBrand->AddItem('--Select--');
      $this->cmbBrand->ItemIndex = $row['brand'];
      $result_brand = mysql_query("select * from lookup_fuel_tbl where company_id='".$_SESSION['company_id']."' and category='brands' order by value asc");

      while($row_brand = mysql_fetch_array($result_brand))
      {
         $this->cmbBrand->AddItem($row_brand['value'], null , $row_brand['value']);
      }


       //list brand
      $this->listFuel->Clear();
      $result_fuel = mysql_query("select * from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='brands' order by value asc");
      while($row_fuel= mysql_fetch_array($result_fuel))
      {
         $this->listFuel->AddItem($row_fuel['value'], null , $row_fuel['value']);
      }


      $this->cmbDealer->ItemIndex = $row['dealer'];
      $result_dealer = mysql_query("select * from lookup_fuel_tbl where company_id='".$_SESSION['company_id']."' and category='dealer names'");

      while($row_dealer = mysql_fetch_array($result_dealer))
      {
         $this->cmbDealer->AddItem($row_dealer['value'], null , $row_dealer['value']);
      }

      //list dealer
      $this->listDealer->Clear();
       $result_deal = mysql_query("select * from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='dealer names'");

       while($row_deal = mysql_fetch_array($result_deal))
        {
            $this->listDealer->AddItem($row_deal['value'], null, $row_deal['value']);
        }



   }

}

global $application;

global $Veh_Fuel_Edit;

//Creates the form
$Veh_Fuel_Edit = new Veh_Fuel_Edit($application);

//Read from resource file
$Veh_Fuel_Edit->loadResource(__FILE__);

//Shows the form
$Veh_Fuel_Edit->show();

?>